package com.cndym.adapterForMobile.mobile.function;

import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cndym.adapterForMobile.BaseFunction;
import com.cndym.exception.ErrCode;
import com.cndym.utils.Utils;
import com.zch.matches.producer.ISportMatchesProducer;

/**
 * 对比赛进行关注或取消关注
 * 
 * @author 朱林虎
 *
 */
@Component
public class FocusSportMatchesFunc extends BaseFunction {
	
	private Logger logger = Logger.getLogger(getClass());
	
	@Autowired
	private ISportMatchesProducer sportMatchesProducer;

	@Override
	public Map<String, String> function(Map<String, String> map) {
		Map<String, String> paramMap = paraMap(map);
		
		if (Utils.isEmpty(paramMap.get("userCode"))) {
			logger.error("userCode不存在，该请求无效！");
			return noBodyReMap(ErrCode.E3004);
		}
		if (Utils.isEmpty(paramMap.get("lotteryCode"))) {
			logger.error("彩种不存在，该请求无效！");
			return noBodyReMap(ErrCode.E3300);
		}

		if (Utils.isEmpty(paramMap.get("gameId"))) {
			logger.error("比赛id（gameId）不存在，该请求无效！");
			return noBodyReMap(ErrCode.E4501);
		}

		if (Utils.isEmpty(paramMap.get("isFocus"))) {
			logger.error("关注或取消（isFocus）不存在，该请求无效！");
			return noBodyReMap(ErrCode.E4503);
		}
		
		if(sportMatchesProducer.focusSportMatches(paramMap)){
			return success();
		}
		return failure();
	}

}
